package com.chinasoft.reposearch.service.scheduler;

import com.chinasoft.reposearch.service.DataCountService;
import com.chinasoft.reposearch.service.DataSyncService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class StatisticScheduler {
    @Autowired
    private final DataSyncService dataSyncService;
    @Autowired
    private final DataCountService dataCountService;


    // 每月第一天凌晨1点执行昨月统计
    @Scheduled(cron = "0 0 1 1 * ?")
    public void monthStatisticJob() {
        dataSyncService.fullSync();
        dataCountService.countLanguage();
        dataCountService.countTopic();
        dataCountService.dumpToMysql();

    }
}